package com.czkevin.cif.events;

import com.czkevin.cif.CIFItemInstance;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;

public class CIFBlockEvent extends PlayerEvent implements Cancellable {
    private static final HandlerList handlerList = new HandlerList();

    private final Action action;
    private final Location location;
    private final CIFItemInstance item;

    private boolean cancelled = false;

    public CIFBlockEvent(Player who, Action action, Location location, CIFItemInstance item) {
        super(who);
        this.action = action;
        this.location = location;
        this.item = item;
    }

    public Location getLocation() {
        return location;
    }

    public Action getAction() {
        return action;
    }

    public CIFItemInstance getItem() {
        return item;
    }

    @Override
    public HandlerList getHandlers() {
        return handlerList;
    }

    public static HandlerList getHandlerList() {
        return handlerList;
    }

    @Override
    public boolean isCancelled() {
        return cancelled;
    }

    @Override
    public void setCancelled(boolean cancel) {
        cancelled = cancel;
    }

    public enum Action {
        PLACE,
        BREAK,
        USE
    }
}
